package src.com.neusoft.nep.common;

import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;

import java.io.IOException;
import java.net.URL;

public class SwitchScene {
    public static void switchScene(Button buttonName, String fxmlPath) throws IOException {
        Stage stage = (Stage)buttonName.getScene().getWindow();
        //加载登录页面的fxml视图
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = SwitchScene.class.getResource(fxmlPath);
        fxmlLoader.setLocation(url);
        Parent root = fxmlLoader.load();
        Scene scene = buttonName.getScene();
        scene.setRoot(root);
        stage.setScene(scene);
        stage.show();
    }
}
